"use strict";

var path = require("path");
var gulp = require("gulp");
var build = path.join(__dirname, "..", "build", "bundle.css");
var dest = path.join(__dirname, "..", "build");
var ext = ".min.css";

/**
 * Minify css.
 *
 * @method cssmin
 */
function cssmin() {
  var plugins = this.opts.plugins;
  return gulp.src(build)
    .pipe(plugins.plumber({
      errorHandler: function(err) {
        plugins.util.log("[cssmin]", err);
      }
    }))
    .pipe(plugins.cssnano())
    .pipe(plugins.rename({
      extname: ext
    }))
    .pipe(gulp.dest(dest));
}
module.exports = cssmin;
